package com.lagou.edu.service.impl;

import com.lagou.edu.dao.ResumeDao;
import com.lagou.edu.pojo.Resume;
import com.lagou.edu.service.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;
import java.util.Optional;

@Service("ResumeService")
public class ResumeServiceImpl implements ResumeService {

    @Autowired
    private ResumeDao resumeDao;


    @Override
    public List<Resume> queryAllResume() {
        return resumeDao.findAll();
    }

    @Override
    public Resume updateResume(Resume resume) {
        Resume newResume = new Resume();
        newResume.setId(30L);
        newResume.setName("hcw");
        newResume.setAddress("66");
        newResume.setPhone("777");
        Resume save = resumeDao.save(newResume);
        System.out.println(save);
        return save;
    }

    @Override
    public Resume update(Resume resume) {
        return resumeDao.save(resume);
    }

    @Override
    public boolean deleteResume(Long id) {
        Optional<Resume> optionalResume = resumeDao.findById(id);
        if (optionalResume.isEmpty()) {
            return false;
        }
        resumeDao.deleteById(id);
        return true;
    }
}
